#include <stdio.h>
#include <stdlib.h>

int main ( int argc, char const *argv[] ) {
    typedef struct monitor {
        int sid;
        char *name;
        int math_score;
        int phy_score;
        int eng_score;
    }Monitor;

    int num = 0, *result, i = 0, *rp;

    printf("Input the number of students:\t");
    scanf("%d",&num);

    result = malloc(sizeof(int)*num);
    rp = result;

    for ( i = 0; i < num; i++ ) {
        Monitor student;
        student.name = malloc(100);
        printf("Please input the %dth student's sid name \
math_score phy_score eng_score\n",i+1);
        scanf("%d %s %d %d %d", &student.sid, &student.name, \
        &student.math_score, &student.phy_score, &student.eng_score);
        *rp = (student.math_score+student.phy_score+student.eng_score) / 3;
        rp++;
        free(student.name);
    }

    for ( i = 0; i < num; i++ ) {
        rp = result + i;
        printf("The average score of the %dth student is %d.\n", i+1, *rp);
    }

    free(result);
    return 0;
}